package com.xcf.mybatis_example.dao.mapper;

import com.xcf.mybatis_example.dao.pojo.UserRoleData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * UserRoleDataMapper <br>
 *
 * @author xiaocf <br>
 * @version 1.0 <br>
 * @date 2020/3/20 15:13 <br>
 */
@Mapper
public interface UserRoleDataMapper {

    @Select("select * from user_role_data urd where urd.role_id = 43791 limit 1 for update")
    UserRoleData select();

    @Insert("INSERT INTO `user_role_data`(`role_id`, `post_num`, `comment_num`, `reply_num`, `post_like_num`, `comment_like_num`, `update_time`, `create_time`) VALUES (43791, 1, 0, 0, 0, 0, '2020-03-20 15:09:39', '2020-03-20 15:09:39')")
    void save();

    @Update("update user_role_data urd set urd.post_num = urd.post_num + 1, urd.update_time = current_timestamp where urd.role_id = 43791")
    void update();
}
